/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * <p>Project: jse2302 - LinkedListAbc
 * <p>Powered by webrx On 2023-06-25 15:36:14
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class LinkedListAbc {
    public static void main(String[] args) {
        long ss = System.currentTimeMillis();
        LinkedList<String> list = new LinkedList<>();
        for (int i = 0; i <= 100000; i++) {
            list.addFirst("LinkedList = " + i);
        }
        long ee = System.currentTimeMillis();
        System.out.println(ee - ss);

        System.out.println("--------------------------");
        ss = System.currentTimeMillis();


        //for (int i = 0; i <= 100000; i++) {
        //    String t = list.get(i);
        //    System.out.println(t);
        //}

        //将集合转换为耗迭代器对象实例
        Iterator<String> it = list.iterator();

        //.hasNext() 返回true false 如果有元素返回true
        System.out.println(list.size());
        
        while (it.hasNext()) {
            //.next() 获取元素。
            String t = it.next();
            System.out.println(t);
        }


        ee = System.currentTimeMillis();
        System.out.println(ee - ss);

        //LinkedList<Integer> list = new LinkedList<>();
        //list.add(10);
        //list.addAll(List.of(1, 2, 3));
        //System.out.println(list);
        //
        ////list.sort((a, b) -> a - b);
        //Collections.sort(list, (a, b) -> a - b);
        //System.out.println(list);

    }
}
